package com.itheima04;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class HomeWork02 {
    public static void main(String[] args) {
        HashMap<Commodity, Integer> hm = new HashMap<>();

        Commodity c1 = new Commodity("华为手机P80", 8888.0);
        Commodity c2 = new Commodity("小米手环", 1666.0);
        Commodity c3 = new Commodity("小米智能音响", 199.0);
        Commodity c4 = new Commodity("电动牙刷", 50.0);

        hm.put(c1, 3);
        hm.put(c2, 10);
        hm.put(c3, 20);
        hm.put(c4, 40);
        int sum = 0;
        Set<Map.Entry<Commodity, Integer>> entries = hm.entrySet();
        for (Map.Entry<Commodity, Integer> entry : entries) {
            Commodity key = entry.getKey();
            Integer value = entry.getValue();
            double danjia = key.getPrice() * value;
            sum += danjia;
        }
        System.out.println("最终要付" + sum+"元");
    }
}
